package org.eclipsecon.swtbot.example;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(SWTBotJunit4ClassRunner.class)
public class PluginTest1 {
    private static SWTWorkbenchBot bot = new SWTWorkbenchBot();

    @BeforeClass
    public static void beforeClass() throws Exception {
        bot.viewByTitle("Welcome").close();
    }

    @AfterClass
    public static void sleep() {
        bot.sleep(5000); // only for demonstration
    }

    @Test
    public void canCreateANewJavaProject() {
        bot.menu("File").menu("New").menu("Project...").click();
        bot.shell("New Project").activate();
        bot.tree().select("Java Project");
        bot.button("Next >").click();
        bot.textWithLabel("Project name:").setText("MyFirstProject");
        bot.button("Finish").click();
        // FIXME Assert the new project has been created.
    }
}